package xiong.myiot;

import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

public class TapSettingActivity extends AppCompatActivity implements MQTTGetMessageCallBack {
    private String TAG="TAP";
    private TextView txt_name;
    private TextView txt_status;
    private ImageButton btn_image;
    private ImageButton btn_switch;
    private ImageButton btn_time;
    private LinearLayout linearLayout;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tap_setting);

        LinearLayout linearLayout = (LinearLayout) findViewById(R.id.page_background);
        TextView txt_name = (TextView) findViewById(R.id.txt_name);
        TextView txt_status = (TextView) findViewById(R.id.txt_status);
        ImageButton btn_image = (ImageButton) findViewById(R.id.btn_image);
        ImageButton btn_switch = (ImageButton) findViewById(R.id.btn_switch);
        ImageButton btn_time = (ImageButton) findViewById(R.id.btn_time);
        txt_name.setText("设备名称");
        txt_status.setText("阀门已打开");
//        linearLayout.setBackgroundColor(Color.BLUE);
        btn_image.setImageResource(R.drawable.pipe);
        btn_switch.setImageResource(R.drawable.switch_white);
        btn_time.setImageResource(R.drawable.clock_white);

        btn_switch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MQTTService.publish("ff6be6ebb6", "XY+TAP=0");
            }
        });
    }

    @Override
    public void setMessage(String topic, String message) {
        Log.d(TAG,"MQTT Recv [" + topic + "]:" + message);
    }
}
